﻿using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using Verse.AI;

namespace Miao.Stand
{
    public class JobDriver_StandWait : JobDriver_Wait
    {
        public override void DecorateWaitToil(Toil wait)
        {
            wait.tickAction += () =>
                 {
                     
                     if (!pawn.Position.InHorDistOf((pawn as StandPawn).owner.Position, (pawn as StandPawn).WanderRanage) || (pawn as StandPawn).ghostFollow)
                     {
                         //Messages.Message("触发立即跟随本体", MessageTypeDefOf.NeutralEvent);
                         job.expiryInterval = 1;//这种方式才触发Pawn_JobTracker，进而执行EndCurrentJob，如果超出范围就立即结束等待
                         //wait.defaultCompleteMode = ToilCompleteMode.Instant;//试试看有没有效果
                     }
                 };
        }
    }
}
